package com.huayi.server.Controller.app;

import com.huayi.server.NioServer.DeviceManager;
import com.huayi.server.Utils.Resp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import redis.clients.jedis.JedisPool;

/**
 * Created by mac on 2017/8/22.
 */
@Controller
@RequestMapping("/deviceinfo")
public class InfoController {

    Logger logger = LoggerFactory.getLogger(InfoController.class);

    @Autowired
    JedisPool jedisPool;

    @Autowired
    Resp resp;

    @Autowired
    DeviceManager deviceManager;

    @RequestMapping("/all")
    @ResponseBody
    public Resp allInfo(){
        logger.info("ssss000:"+deviceManager.toString());
        resp.setData(deviceManager.allInfo());
        return resp;
    }

    @RequestMapping("/info/{id}")
    @ResponseBody
    public Resp info(@PathVariable String id){
        logger.info("id:"+id);
        resp.setData(deviceManager.get(id));
        return resp;
    }
}
